package com.andon.microcellsimulator.common.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.andon.microcellsimulator.R;

/**
 * Created by Administrator on 2015/6/25.
 */
public class ZnkProgressDialog extends Dialog {

    private Context mContent;

    private ZnkProgressDialog(Context context){
        super(context, R.style.znk_progress_dialog);
        mContent = context;

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        this.setIndeterminateDrawable(mContent.getResources().getDrawable(R.drawable.customer_progess_dialog)) ;
//        this.setCanceledOnTouchOutside(false);

    }


    public static ZnkProgressDialog createLoadingDialog(Context context,String message){

        View view = LayoutInflater.from(context).inflate(R.layout.loading_dialog, null);
        LinearLayout layout = (LinearLayout) view.findViewById(R.id.loading_view);
        ImageView loadingImg = (ImageView) view.findViewById(R.id.loading_img);
        TextView loadingTip = (TextView) view.findViewById(R.id.loading_tip);

        // 加载动画
        loadingImg.startAnimation(AnimationUtils.loadAnimation(context, R.anim.loading_anim));
        // 设置提示文字
        loadingTip.setText(message);

        ZnkProgressDialog dialog = new ZnkProgressDialog(context);
        dialog.setCanceledOnTouchOutside(false);
        dialog.setContentView(layout, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT));
        return dialog;
    }
}
